#pragma once
#ifndef Particles_h__
#define Particles_h__

#include "Gfx.h"
#include "Geo.h"

#include <eastl/vector.h>

enum { PT_Img, PT_Text };

struct Part
{
	Pic Img;
	const char* Text;
	Vec Pos;
	Vec Speed;
	Vec Accel;
	float Angle;
	float AngleSpeed;
	Color Col;
	float Life;
	int Data;
	int Type;

	Part() : Img(0), Text(0), Pos(0,0), Speed(0,0), Accel(0,0), Angle(0), AngleSpeed(0), Life(0), Data(0), Type(0) {}

	inline void Age(float dt)
	{
		if (Life > 0)
		{
			Angle += AngleSpeed*dt;
			Speed = Speed + Accel*dt;
			Pos = Pos + Speed*dt;
			Life -= dt;
		}
	}
};

extern eastl::vector<Part> Particles;
extern Fnt ParticleFont;

Part* AddParticle(const Vec& position, const Part* definition = 0);
Part* ShootParticle(const Vec& position, const Vec& velocity, const Part* definition = 0);
void DoParticles(float dt);
void DrawParticles(const Vec& offset = Vec(0,0));

#endif // Particles_h__